package org.jash.shop2112.utils

import com.google.gson.Gson
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter

class StringToMap:TypeAdapter<Map<String, List<String>>>() {
    private val gson = Gson()
    override fun write(out: JsonWriter?, value: Map<String, List<String>>?) {
        out?.value(gson.toJson(value))
    }

    override fun read(`in`: JsonReader?): Map<String, List<String>>?  = `in`?.let { gson.fromJson(it.nextString(), Map::class.java) as Map<String, List<String>> }
}